<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/base_body_header.jsp" %>
<%@include file="../common/navbar.jsp" %>
<%@include file="../common/page_content_pre.jsp" %>

<link rel="stylesheet" href="${GLOBAL.staticJsPath}/assets/fileinput/fileinput.css"/>

<div class="page-content">

    <div class="row">
        <div class="col-sm-12">
            <div class="widget-box">
                <div class="widget-header">
                    <h4>${not empty cellInfo.cellId?'修改':'添加'}楼座</h4>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <form:form class="form-horizontal" modelAttribute="cellInfo"
                                   action="${GLOBAL.basePath}/cellInfo/save" method="post" id="cellInfoForm">
                            <form:hidden path="cellId"/>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">楼栋号：</label>

                                    <div class="col-sm-6">
                                        <form:input path="buildingNo" htmlEscape="false" maxlength="150"
                                                    class="input-xlarge required" placeholder="请输入楼栋号"/>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                                <form:input path="nbhId" type="hidden"/>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">单元号：</label>

                                    <div class="col-sm-5">
                                        <form:input path="unitNum" htmlEscape="false" type = "number"
                                                    class="input-xlarge required" placeholder="请输入单元号"/>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">门牌号：</label>

                                    <div class="col-sm-5">
                                        <form:input path="residenters" htmlEscape="false" maxlength="50"
                                                    class="input-xlarge required" placeholder="请输入总户数"/>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">总层数：</label>

                                    <div class="col-sm-5">
                                        <form:input path="totalFloor" htmlEscape="false" type = "number"
                                                    class="input-xlarge required" placeholder="请输入总层数"/>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <div class="form-actions center">
                                <button type="button" class="btn btn-sm btn-grey" id="go_back_btn">
                                    返回
                                    <i class="icon-reply icon-on-right bigger-110"></i>
                                </button>
                                <shiro:hasPermission name='cellInfo:edit'>
                                    <button type="submit" class="btn btn-sm btn-success" id="save_btn">
                                        保存
                                        <i class="icon-save icon-on-right bigger-110"></i>
                                    </button>
                                </shiro:hasPermission>
                            </div>
                        </form:form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<%@include file="../common/page_content_suf.jsp" %>
<%@include file="../common/script.jsp" %>

<script type="text/javascript">
    $(document).ready(function () {
        $("#cellInfoForm").validate({
            rules: {
                mobile: {
                    remote: {
                        type: "POST",
                        cache: false,
                        url: "${GLOBAL.basePath}/cellInfo/check",
                        data: {
                            oldAccount: function () {
                                return "${sysUser.mobile}";
                            },
                        }
                    }
                }
            },
            messages: {
                mobile: {required: "用户登录名不能为空", remote: jQuery.format("用户登录名已存在")},
                confirmNewPassword: {equalTo: "输入与上面相同的密码"}
            },
            errorContainer: "#messageBox",
        });

        $("#go_back_btn").on("click", function () {
            goBack();
        });
    });

    function goBack() {
        document.location.href = "${GLOBAL.basePath}/cellInfo/list";
    }
</script>
